package com.ablecisi.item;

import com.ablecisi.AblecisiFirstMod;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

/**
 * ablecisi_first_mod-template-1.20.1
 * com.ablecisi.item
 * ModItems <br>
 *
 * @author Ablecisi
 * @version 1.0
 * 2025/4/21
 * 星期一
 * 16:28
 */
public class ModItems {
    public static final Item ICE_ETHER = registerItems("ice_ether",
            new Item(new FabricItemSettings()));
    public static final Item FIRE_ETHER = registerItems("fire_ether",
            new Item(new FabricItemSettings()));

    private static void addItemsToItemGroup1(FabricItemGroupEntries fabricItemGroupEntries) {
        fabricItemGroupEntries.add(ICE_ETHER);
    }

    private static void addItemsToItemGroup2(FabricItemGroupEntries fabricItemGroupEntries) {
        fabricItemGroupEntries.add(FIRE_ETHER);
    }

    private static Item registerItems(String name, Item item) {
        // 注册物品
        return Registry.register(Registries.ITEM, new Identifier(AblecisiFirstMod.MOD_ID, name), item);
    }

    public static void registerModItems() {
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(ModItems::addItemsToItemGroup1);
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(ModItems::addItemsToItemGroup2);
    }
}
